package com.baicaoyuan.web.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

/**
 * 是否为合作商户
 */
@RequiredArgsConstructor
@Getter
public enum UserBusinessEnum {

    /**
     * 合作商户
     */
    COOPERATIVE_MERCHANT("2"),

    /**
     * 普通平台
     */
    GENERAL("1");

    private final String status;

    /**
     * 根据标识获取枚举
     *
     * @param category
     * @return
     */
    public static UserBusinessEnum acquire(final String category) {
        Optional<UserBusinessEnum> categoryEnum = Arrays.stream(UserBusinessEnum.values())
                .filter(c -> (Objects.equals(c.status, category)))
                .findFirst();
        return categoryEnum.orElse(UserBusinessEnum.GENERAL);
    }
}
